package com.skp.shaphan.ui.windows;

import java.awt.Container;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

import com.skp.lydia.layout.CSSLayout;
import com.skp.shaphan.ui.buttons.DialogCancelButton;

public class CompareOutputWindow extends JDialog {
	private JProgressBar recProgress;
	private JTextArea txtOut;

	public CompareOutputWindow(JFrame parent) {
		super(parent, "Compare");
		setSize(300, 300);
		Container cp = getContentPane();
		cp.setLayout(new CSSLayout());
		
		JLabel label = new JLabel("Records Progress:");
		cp.add(label, "left-margin: 5; top-margin: 5");
		
		recProgress = new JProgressBar();
		cp.add(recProgress, "display: inline; left-margin: 5; top-margin: 5; width: 100%");
		
		label = new JLabel("Results");
		cp.add(label, "left-margin: 5; top-margin: 5");
		
		txtOut = new JTextArea(10, 100);
		JScrollPane scroll = new JScrollPane(txtOut);
		cp.add(scroll, "left-margin: 5; width: 100%; height: 200");

		DialogCancelButton cancel = new DialogCancelButton(this);
		cp.add(cancel, "left-margin: 5; top-margin: 5");
	}
	
	public void nextRecord(String recName) {
		txtOut.append("\n - " + recName);
		recProgress.setValue(recProgress.getValue() + 1);
	}
	
	public void addinfo(String info) {
		txtOut.append("\n    " + info);
	}
	
	public void setRecordCount(int count) {
		recProgress.setMaximum(count);
		recProgress.setValue(0);
	}
}
